package com.tools.pojo.workflow.bo;

import com.tools.common.result.Result;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class NodeExecutionResult {

    private boolean success;
    private String message;
    private Object data;

    public static NodeExecutionResult success(String message) {
        return success(message, null);
    }

    public static NodeExecutionResult success(String message, Object data) {
        NodeExecutionResult result = new NodeExecutionResult();
        result.setSuccess(true);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static NodeExecutionResult failure(String message) {
        NodeExecutionResult result = new NodeExecutionResult();
        result.setSuccess(false);
        result.setMessage(message);
        return result;
    }

    public static NodeExecutionResult fromStepResult(Result<?> stepResult) {
        NodeExecutionResult result = new NodeExecutionResult();
        result.setSuccess(stepResult.isSuccess());
        result.setMessage(stepResult.getMessage());
        result.setData(stepResult.getData());
        return result;
    }

}
